package com.lh;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import com.lh.service.DemoService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author hy
 * @description 使用注解的方式创建dubbo项目--客户端
 * @date 2019-10-07
 */
@Configuration
@EnableDubbo(scanBasePackages = "com.lh")//启用Dubbo扫描并注入对象
@PropertySource("classpath:dubbo-customer.properties")//扫描配置文件
public class Customer2 {

    @Reference
    DemoService demoService;//这里需要使用Dubbo来进行注入

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Customer2.class);
        Customer2 customer = context.getBean(Customer2.class);
        String say = customer.demoService.hello("World");
        System.out.println(say);
    }

}



